home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / libelf / elf_strptr.z / elf_strptr
Encoding:
Text File  |  2002-10-03  |  3.6 KB  |  75 lines

  1. ELF_STRPTR(3E)                                       Last changed: 10-13-98
  2.  
  3.  
  4. NNAAMMEE
  5.      eellff__ssttrrppttrr - Makes a string pointer
  6.  
  7. SSYYNNOOPPSSIISS
  8.      cccc [_f_l_a_g ...] _f_i_l_e ...  --lleellff [_l_i_b_r_a_r_y ...]
  9.  
  10.      ##iinncclluuddee <<lliibbeellff..hh>>
  11.  
  12.      cchhaarr **eellff__ssttrrppttrr((EEllff **eellff,, ssiizzee__tt sseeccttiioonn,, ssiizzee__tt ooffffsseett));;
  13.  
  14.      ##ddeeffiinnee __LLIIBBEELLFF__XXTTNNDD__6644
  15.  
  16.      cchhaarr **eellff__ssttrrppttrr((EEllff **eellff,, EEllff6644__XXwwoorrdd sseeccttiioonn,, EEllff6644__XXwwoorrdd ssiizzee__tt
  17.      ooffffsseett));;
  18.  
  19. IIMMPPLLEEMMEENNTTAATTIIOONN
  20.      IRIX systems
  21.  
  22. DDEESSCCRRIIPPTTIIOONN
  23.      This function converts a string section ooffffsseett to a string pointer.
  24.      eellff identifies the file in which the string section resides, and
  25.      sseeccttiioonn gives the section table index for the strings.  eellff__ssttrrppttrr
  26.      normally returns a pointer to a string.  If eellff is null, sseeccttiioonn is
  27.      invalid or is not a section of type SSHHTT__SSTTRRTTAABB, the section data
  28.      cannot be obtained, ooffffsseett is invalid, or an error occurs, it returns
  29.      a null pointer.
  30.  
  31. NNOOTTEESS
  32.      A program may call eellff__ggeettddaattaa to retrieve an entire string table
  33.      section.  For some applications, that would be both more efficient and
  34.      more convenient than using eellff__ssttrrppttrr.
  35.  
  36.      The use of a ssiizzee__tt in a 32-bit compile with eellff__ssttrrppttrr is
  37.      unfortunate, since that makes it impossible to deal with certain
  38.      object files.  If, when the 32-bit app is compiled, __LLIIBBEELLFF__XXTTNNDD__6644 is
  39.      defined, then the function interface changes to have 64-bit fields.
  40.      If __LLIIBBEELLFF__XXTTNNDD__6644 is defined at compile-time, then instead of linking
  41.      with --lleellff, link with --lleellff__xxttnndd.  There is a corresponding
  42.      --llddwwaarrff__xxttnndd.  It is essential that a 32-bit application compiled with
  43.      __LLIIBBEELLFF__XXTTNNDD__6644 be entirely compiled with __LLIIBBEELLFF__XXTTNNDD__6644 defined.
  44.  
  45.      Applications that are built as 64-bit applications can ignore
  46.      __LLIIBBEELLFF__XXTTNNDD__6644: it has no effect on them and 64-bit applications
  47.      always link with --lleellff, never with --lleellff__xxttnndd.
  48.  
  49. EEXXAAMMPPLLEESS
  50.      The following is a prototype for retrieving section names.  The file
  51.      header specifies the section name string table in the ee__sshhssttrrnnddxx
  52.      member.  The following code loops through the sections, printing their
  53.      names.
  54.  
  55.           if ((ehdr = elf32_getehdr(elf)) == 0)
  56.           {
  57.                /* handle the error */
  58.                return;
  59.           }
  60.           ndx = ehdr->e_shstrndx;
  61.           scn = 0;
  62.           while ((scn = elf_nextscn(elf, scn)) != 0)
  63.           {
  64.                char *name = 0;
  65.                if ((shdr = elf32_getshdr(scn)) != 0)
  66.                  name = elf_strptr(elf, ndx, (size_t)shdr->sh_name);
  67.                printf("'%s'\n", name? name: "(null)");
  68.           }
  69.  
  70. SSEEEE AALLSSOO
  71.      eellff(3E), eellff__ggeettddaattaa(3E), eellff__ggeettsshhddrr(3E), eellff__xxllaattee(3E)
  72.  
  73.      This man page is available only online.
  74.  
  75.